package unei;

import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;

/**
 * Created by sunlei on 2015/7/2.
 */
public class ReduceTest {
    public static void main(String[] args){
        List<Integer> list=new ArrayList();
        list.add(1);
        list.add(2);
        list.add(3);
        BiFunction<Integer,Integer,Integer> biFunction=(i1,i2) -> i1+i2;
        BinaryOperator<Integer> binaryOperator=(a,b)-> {System.out.println(a+b); return a+b;};
        Integer res=list.stream().parallel().reduce(0,biFunction,binaryOperator);
        System.out.println(res);
    }
}
